stap=0.01;seq=seq(0.005,0.995,0.01);par(mfrow=c(1,2))

# READ IN 4 PROFILES

X1=apply(PROFILE_1_50_500,1,mean)
Y1=apply(PROFILE_1_50_500,1,sd)
X2=apply(PROFILE_2_50_500,1,mean)
Y2=apply(PROFILE_2_50_500,1,sd)

D1=dnorm(seq,0.40,0.04);D1=D1/(sum(D1)*stap)
D2=dnorm(seq,0.70,0.10);D2=D2/(sum(D2)*stap)
G1=(D1+D2)/2
G2=dnorm(seq,0.45,0.15);G2=G2/(sum(G2)*stap)

plot(seq,X1,col='magenta',type='l',lwd=2,ylim=c(0,8),axes=FALSE,
main=c(paste('4A. Estimated Respondent Profiles for'),
paste('Group 1 (mean=.55) and Group 2 (mean=.45)'),
paste('Estimated Profile-Based Cliffs Delta = .29'),
paste('Its 99% Confidence Interval = (-.00, .56)')),
xlab='Probability of Behaviour',ylab='Plausibility')
axis(side=1,at=seq(0,1,0.10));axis(side=2,at=seq(0,8,2),las=1)
lines(seq,X2,col='green3',lwd=2)
lines(seq,G1,col='blue',lwd=2,lty=2)
lines(seq,G2,col='red',lwd=2,lty=2)
legend('topright',bty='n',cex=.9,
c('Estimated Profile Group 1','Reference Profile Group 1',
'Estimated Profile Group 2','Reference Profile Group 2'),
col=c('magenta','blue','green3','red'),lty=c(1,2,1,2))

K1=X1+2.576*Y1;lines(seq,K1,col='magenta',lty=2)
L1=X1-2.576*Y1;L1[L1<0]=0;lines(seq,L1,col='magenta',lty=2)

K2=X2+2.576*Y2;lines(seq,K2,col='green3',lty=2)
L2=X2-2.576*Y2;L2[L2<0]=0;lines(seq,L2,col='green3',lty=2)

##########################################################

X1=apply(PROFILE_3_500_500,1,mean)
Y1=apply(PROFILE_3_500_500,1,sd)
X2=apply(PROFILE_4_500_500,1,mean)
Y2=apply(PROFILE_4_500_500,1,sd)

plot(seq,X1,col='magenta',type='l',lwd=2,ylim=c(0,8),axes=FALSE,
main=c(paste('4B. Estimated Respondent Profiles for'),
paste('Group 1 (mean=.55) and Group 2 (mean=.45)'),
paste('Estimated Profile-Based Cliffs Delta = .29'),
paste('Its 99% Confidence Interval = (.20, .38)')),
xlab='Probability of Behaviour',ylab='Plausibility')
axis(side=1,at=seq(0,1,0.10));axis(side=2,at=seq(0,8,2),las=1)
lines(seq,X2,col='green3',lwd=2)
lines(seq,G1,col='blue',lwd=2,lty=2)
lines(seq,G2,col='red',lwd=2,lty=2)
legend('topright',bty='n',cex=.9,
c('Estimated Profile Group 1','Reference Profile Group 1',
'Estimated Profile Group 2','Reference Profile Group 2'),
col=c('magenta','blue','green3','red'),lty=c(1,2,1,2))

K1=X1+2.576*Y1;lines(seq,K1,col='magenta',lty=2)
L1=X1-2.576*Y1;L1[L1<0]=0;lines(seq,L1,col='magenta',lty=2)

K2=X2+2.576*Y2;lines(seq,K2,col='green3',lty=2)
L2=X2-2.576*Y2;L2[L2<0]=0;lines(seq,L2,col='green3',lty=2)



